//
//  KRChooseCell.m
//  KEREN
//
//  Created by MW on 2023/4/10.
//

#import "KRChooseCell.h"

@implementation KRChooseCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.chooseView.userInteractionEnabled = YES;
    _hoursBtn = [UIButton setButtonWithTitle:@"小时" titleColor:Color_86898E titleFont:BFont(12) cornerRadius:13 backColor:[UIColor clearColor]];
    _dayBtn = [UIButton setButtonWithTitle:@"天" titleColor:Color_86898E titleFont:BFont(12) cornerRadius:13 backColor:[UIColor clearColor]];
    [self.chooseView addSubview:_hoursBtn];
    [self.chooseView addSubview:_dayBtn];
    [_dayBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-2);
        make.height.offset(26);
        make.width.offset(28);
        make.centerY.equalTo(self.chooseView);
    }];
    [_hoursBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(2);
        make.height.offset(26);
        make.right.equalTo(_dayBtn.mas_left).offset(0);
        make.centerY.equalTo(self.chooseView);
    }];

    _dayBtn.selected = YES;
    _dayBtn.backgroundColor = Color_7ACC00;
    _dayBtn.layer.cornerRadius = 13;
    _dayBtn.clipsToBounds = YES;
    [_dayBtn setTitleColor:Whire_Color forState:UIControlStateNormal];
    _hoursBtn.layer.cornerRadius = 13;
    _hoursBtn.clipsToBounds = YES;

    [_dayBtn addTarget:self action:@selector(dayBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [_hoursBtn addTarget:self action:@selector(hoursBtnClick) forControlEvents:UIControlEventTouchUpInside];
    _textField = [UITextField setFlieldplaceholder:@"请输入数字" Font:Font(16) borderColor:Color_86898E];
    _textField.rightViewMode = UITextFieldViewModeNever;

    [self addSubview:_textField];
    [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(24);
        make.right.offset(-24);
        make.height.offset(72);
        make.bottom.offset(-16);
    }];
    _textField.hidden = YES;
    _textField.keyboardType = UIKeyboardTypeNumberPad;
    [self addSubview:_textField];
    _tipsLbl.hidden = YES;
    // Initialization code
}
- (void)dayBtnClick{
    _dayBtn.selected = YES;
    _hoursBtn.selected = NO;
    _dayBtn.backgroundColor = Color_7ACC00;
    _hoursBtn.backgroundColor = [UIColor clearColor];
    [_dayBtn setTitleColor:Whire_Color forState:UIControlStateNormal];
    [_hoursBtn setTitleColor:Color_86898E forState:UIControlStateNormal];
    self.changeShareType(YES);
}
- (void)hoursBtnClick{
    _hoursBtn.selected = YES;
    _dayBtn.selected = NO;
    _hoursBtn.backgroundColor = Color_7ACC00;
    _dayBtn.backgroundColor = [UIColor clearColor];
    [_hoursBtn setTitleColor:Whire_Color forState:UIControlStateNormal];
    [_dayBtn setTitleColor:Color_86898E forState:UIControlStateNormal];
    self.changeShareType(NO);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
